package com.example.administrator.kaohedemo.Activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.Window;

import com.example.administrator.kaohedemo.Action.ActionCreator;
import com.example.administrator.kaohedemo.Dispatcher.Dispatcher;
import com.example.administrator.kaohedemo.Store.Store;

/**
 * Created by Administrator on 2016/6/21.
 */
public abstract class BaseActivity extends FragmentActivity implements View.OnClickListener{

    protected Dispatcher dispatcher;
    protected Store store;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        initARC();
        initView();
        initListener();
        initData();
    }

    private void initARC() {
        dispatcher=Dispatcher.getInstense();
        store=getStore();
    }

    protected abstract Store getStore();
    protected abstract void initView();
    protected abstract void initListener();
    protected abstract void initData();


    @Override
    protected void onResume() {
        super.onResume();
        dispatcher.register(this);
        dispatcher.register(store);
    }

    @Override
    protected void onStop() {
        super.onStop();
        dispatcher.unregister(this);
        dispatcher.unregister(store);
    }
}
